package com.wuhuahe.luanfeng;


import org.junit.Assert;
import org.junit.Test;

/**
 * Created By wuhuahe
 * author:游龙
 * Date: 2018-07-23
 * Time: 20:47
 * Desc:
 */
public class Fib {

    private static long loop(int n, long a0, long a1){
        if(n <=1 ) return a1;
        else return loop(n-1, a1, a0 + a1);
    }

    public static long fib(int n){
        return loop(n, 0, 1);
    }

    @Test
    public void testFib(){
        Assert.assertEquals(5, fib(5));
    }
}
